﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OOLib
{
   /// <summary>
   /// Extends a SimpleText by the capability of inserting TextContents.
   /// </summary>
   public class Text : SimpleText
   {
      #region Constructors

      /// <summary>
      /// Constructor
      /// </summary>
      /// <remarks>
      /// After using this constructor, the ComObj must be set manually!
      /// </remarks>
      public Text() :
         base()
      { }

      /// <summary>
      /// Constructor
      /// </summary>
      /// <param name="comObject">COM object</param>
      public Text(object comObject) :
         base(comObject)
      { }

      #endregion

      #region XText
      
      /// <summary>
      /// Inserts a content, such as a text table, text frame or text field.
      /// </summary>
      /// <param name="range">Specifies the position of insertion.</param>
      /// <param name="content">The text content to be inserted.</param>
      /// <param name="absorb">
      /// Specifies whether the text spanned by xRange will be replaced. 
      /// If true then the content of range will be replaced by content, otherwise content will be inserted at the end of range.
      /// </param>
      /// <remarks>
      /// Which contents are accepted is implementation-specific. Some implementations may only accept contents 
      /// which were created by the factory that supplied the same text or the document which contains the text. 
      /// </remarks>
      public void InsertTextContent(TextRange range, TextContent content, bool absorb)
      {
         CheckDisposed();
         InvokeMethod("insertTextContent", range.ComObj, content.ComObj, absorb);
      }

      /// <summary>
      /// Removes the specified content from the text object. 
      /// </summary>
      /// <param name="content">The text content to be removed.</param>
      public void RemoveTextContent(TextContent content)
      {
         CheckDisposed();
         InvokeMethod("removeTextContent", content.ComObj);
      }

      #endregion
   }
}
